﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using Portal.Environment;
using Portal.Language;
using Portal.Interface;

namespace Portal.CMS
{
    public class WfPublishingGroupNews : WorkflowFunctionInt
    {
        public string Id
        {
            get
            {
                return "WfPublishingGroupNews";
            }
        }
        public string Name
        {
            get
            {
                return "Phát hành nhóm tin tức lên website";
            }
        }

        public object Execute(WorkFlowLibrary.WorkFlowApp wf, WorkFlowLibrary.Model.WorkFlowRecordCls wfRecordCls, string Id)
        {
            //tao o day....!
            try
            {
                Environments.CheckSessionTimeOut(true);

                string SubGroupNewsItemId = wfRecordCls.Id;
                GroupNewsItemCls
                    GroupNewsItemCls = new GroupNewsBLL().CreateModelItem(Environments.ActiveLanguage, SubGroupNewsItemId);

                string GroupNewsId = GroupNewsItemCls.GroupNewsId;
                string GroupNewsItemId = GroupNewsItemCls.ParentGroupNewsItemId;
                
                new GroupNewsBLL().PublicGroupNewsItemSub(GroupNewsId, GroupNewsItemId, SubGroupNewsItemId);
                return ResourceBLL.GetText("WfPublishingGroupNews", "PublicOk", "Xuất bản lên website (public) thành công");
            }
            catch (Exception ex)
            {
                return "ERROR: " + ex.Message.ToString();
            }
        }
    }
}
